]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
telepathyClient: ignore invalidated channels
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 5 Jun 2012 10:39:30 +0000 (12:39 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 18 Jun 2012 07:56:12 +0000 (09:56 +0200)
There is a race if a channel is invalidated during its preparation: the
'invalidated' signal is already emitted so the Shell will never notice.
We fix this by simply checking if the channel is already invalidated when
receiving it from telepathy-glib.

In the approving case, we reject the full ChannelDispatchOperation as we only
support approving one channel at the time.

https://bugzilla.gnome.org/show_bug.cgi?id=677457

js/ui/telepathyClient.js
src/shell-tp-client.c
src/shell-tp-client.h

index ca60e31a071bffe922cae0d320c5b6e4ef559b82..cfeee474718363e45f722cdc2811cf7422abc24e 100644 (file)
@@ -132,6 +132,9 @@ const Client = new Lang.Class({
             let channel = channels[i];
             let [targetHandle, targetHandleType] = channel.get_handle();
 
+            if (Shell.is_channel_invalidated(channel))
+              continue;
+
             /* Only observe contact text channels */
             if ((!(channel instanceof Tp.TextChannel)) ||
                targetHandleType != Tp.HandleType.CONTACT)
@@ -181,6 +184,9 @@ const Client = new Lang.Class({
                 continue;
             }
 
+            if (Shell.is_channel_invalidated(channel))
+              continue;
+
             // 'notify' will be true when coming from an actual HandleChannels
             // call, and not when from a successful Claim call. The point is
             // we don't want to notify for a channel we just claimed which
@@ -231,6 +237,11 @@ const Client = new Lang.Class({
         let channel = channels[0];
         let chanType = channel.get_channel_type();
 
+        if (Shell.is_channel_invalidated(channel)) {
+            Shell.decline_dispatch_op(context, 'Channel is invalidated');
+            return;
+        }
+
         if (chanType == Tp.IFACE_CHANNEL_TYPE_TEXT)
             this._approveTextChannel(account, conn, channel, dispatchOp, context);
         else if (chanType == Tp.IFACE_CHANNEL_TYPE_CALL)
index 69da10fd292c78c580c37bca483900878168968e..8dc3492413feac788375715ff29c1b50bcf235aa 100644 (file)
@@ -341,3 +341,9 @@ shell_decline_dispatch_op (TpAddDispatchOperationContext *context,
   tp_add_dispatch_operation_context_fail (context, error);
   g_error_free (error);
 }
+
+/* gjs doesn't cope with tp_proxy_get_invalidated() returning a GError */
+gboolean shell_is_channel_invalidated (TpChannel *channel)
+{
+  return tp_proxy_get_invalidated (channel) != NULL;
+}
index 7406b701687cb9691235d48557ae3a5ef68415be..c39c78f6d1250c4624cf8499ceadd3113c7a09cf 100644 (file)
@@ -105,5 +105,7 @@ void shell_tp_client_grab_contact_list_changed (ShellTpClient *self,
 void shell_decline_dispatch_op (TpAddDispatchOperationContext *context,
                                 const gchar *message);
 
+gboolean shell_is_channel_invalidated (TpChannel *channel);
+
 G_END_DECLS
 #endif /* __SHELL_TP_CLIENT_H__ */